package com.simple.business.domain.enumeration;

import com.github.zuihou.base.BaseEnum;
import com.simple.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "InterviewType", description = "测评类型，HOLLAND,MBTI,DISC")
public enum EvaluationTypeEnum implements BaseEnum {

    HOLLAND("霍兰德职业兴趣测评"),
    MBTI("MBTI-16型人格测试"),
    DISC("DISC职业性格测试"),

    /**
     * N="否"
     */
    N("否"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static EvaluationTypeEnum match(String val, EvaluationTypeEnum def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static EvaluationTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(EvaluationTypeEnum val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码")
    public String getCode() {
        return this.name();
    }

    public static String getDescByCode(String code) {
        for (EvaluationTypeEnum value : values()) {
            if (StringUtils.equalsIgnoreCase(code, value.getCode())) {
                return value.getDesc();
            }
        }
        return "";
    }


}
